<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }
  *{
    list-style:none;
  }
  /*body{*/

  /*}*/
  .weui-cell_select {
    padding: 10px 15px;
  }
  .weui-cells__title {
    text-align: left;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  input.time {
    border: none;
    font-size: 16px;
    padding-left: 10px;
  }
  .cell {
    border: 1px solid #ccc;
    height: 18px;
    width: 18px;
    margin-right: 8px;
  }
</style>
<template>
  <div class="oitem" style="border-bottom: 1px dotted #eee;">
<!--      <div class="weui-cells__title">货品明细{{itemNo + 1}}-->
<!--        <p id="acts" style="float: right;color: #1aad19;" v-if="isLast">-->
<!--        <span id="addItem" @click="addItem" style="padding-right: 5px;">添加</span>-->
<!--          <span v-if="itemNo != 0">|</span>-->
<!--          <span id="delItem" style="padding-left: 5px;" @click="delItem" v-if="itemNo != 0">删除</span>-->
<!--        </p>-->
<!--      </div>-->
<!--      <div class="weui-cell weui-cell_select fir">-->
<!--        <div class="weui-cell__hd"><label class="weui-label">产品</label></div>-->
<!--        <div class="weui-cell__bd">-->
<!--          <input type="hidden" class="product" :value="product.productId">-->
<!--          <input type="hidden" :value="product.productName">-->
<!--          <input type="hidden" :value="product.type">-->
<!--          <select class="weui-select" v-model="product">-->
<!--            <option value="" disabled>请选择</option>-->
<!--            <option v-for="(item, index) in products" :value="item">{{item.productName}}</option>-->
<!--          </select>-->
<!--        </div>-->
<!--      </div>-->
    <div class="weui-cells_radio">
      <label class="weui-cell weui-check__label" :for="product.guid">
        <div class="weui-cell__hd" style="display: flex;">
          <input type="checkbox" class="weui-check" name="checkbox1" id="s11" checked="checked" v-model="isChecked" :id="product.guid">
          <i class="weui-icon-checked cell"></i>
        </div>
        <div class="weui-cell__bd" style="text-align: left;">
          <p>{{product.product}}-{{product.spename}}</p>
        </div>
      </label>
    </div>
<!--      <div class="weui-cell weui-cell_select">-->
<!--        <div class="weui-cell__hd"><label class="weui-label">规格</label></div>-->
<!--        <div class="weui-cell__bd">-->
<!--          <input type="hidden" class="specif" :value="spec.speid">-->
<!--          <input type="hidden" :value="spec.spename">-->
<!--          <input type="hidden" :value="spec.stockunit" />-->
<!--          <input type="hidden" :value="spec.stockunitid" />-->
<!--          <select class="weui-select" v-model="spec">-->
<!--            <option value="" disabled>请选择</option>-->
<!--            <option v-for="(item, index) in specs" :value="item">{{item.spename}}</option>-->
<!--          </select>-->
<!--        </div>-->
<!--      </div>-->
    </div>

</template>

<script>
export default {
  name: 'MaterRetApplyItem',
  data () {
    return {
      product: '',
      spec: '',
      specid: '',
      // products: [],
      specs: [],
      isChecked: false
    }
  },
  props: [
    'itemNo',
    'isLast',
    'applyid',
    'picktype',
    'product'
  ],
  watch: {
    // 'product': function (val) {
    //   // console.log('val:', val)
    //   // this.getSpecif(val);
    //   this.doEmitter();
    // },
    'isChecked': function(val) {
      if (val) {
        this.doEmitter();
      } else {
        this.delItem();
      }
    },
    // 'spec.guid': function (val) {
    //   this.doEmitter();
    // },
    applyid: function (val) {
      // this.getProducts();
    },
  },
  mounted() {
    console.log('product:', this.product)
  },
  methods: {
    takePro(e) {
      console.log('e:', e)
    },
    doEmitter(){
      console.log('doEmitter this.product:', this.product)
      this.model = {
        type: this.product.picktype,
        productid: this.product.productid,
        productname: this.product.product,
        specguid: this.product.speid,
        specname: this.product.spename,
        stockunit: this.product.stockunit,
        stockunitid: this.product.stockunitid,
      };
      this.model.index = this.itemNo;
      console.log('doEmitter this.model:', this.model)
      this.$emit('changeData', this.model);
    },
    getProducts: function() {
      if (!this.applyid) return;
      this.axios({
        method: 'get',
        url: '/prod-api/produce/pickinglist/getProducts',
        params: {pickinglistid: this.applyid}
      }).then((response) => {
        if (response.data.code == 200) {
          let data = response.data;
          this.products = data.products;
        } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
          this.toastText("获取产品数据失败");
        }

      })
    },
    getSpecif: function() {
      if (this.product.productId == '') return;
      this.axios({
        method: 'get',
        url: '/prod-api/produce/pickinglist/getSpes',
        params: {pickid: this.applyid, productid: this.product.productId}
      }).then((response) => {
        if (response.data.code == 200) {
          this.specs = response.data.data;
        } else {
          this.toastText('获取规格数据失败')
        }
      })
    },
    addItem: function() {
      this.$emit('doAddItem');
    },
    delItem: function() {
      console.log('执行了')
      this.$emit('doDelItem', this.itemNo);
    }
  }
}
</script>
